package com.bookmarket.test;

import com.bookmarket.entity.Address;
import com.bookmarket.entity.Book;
import com.bookmarket.entity.Custom;
import com.bookmarket.entity.Shop;
import com.bookmarket.service.IProductListService;
import com.bookmarket.service.LJOrderListService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-mybatis.xml")
public class LJDemo {

    @Resource
    private IProductListService iProductListService;
    @Resource
    private LJOrderListService ljOrderListService;

    @Test
    public void test1(){
        /*
        Book book = new Book();
        book.setName("西");
        List<Book> list = iProductListService.aaa(0,book);
        for(Book b : list){
            System.out.println(b.getName());
        }*/
    }
    @Test//测试评论
    public void test2(){
        int a=iProductListService.Count(20);
        System.out.println(a);
    }
    @Test//测试添加购物车
    public void rest3(){
        Custom c=new Custom();
        c.setId(1);
        Book b=new Book();
        b.setId(20);

        Shop s=new Shop();
        s.setBook_picture("jh");
        s.setBook_price(Float.parseFloat("25"));
        s.setBook_name("诛仙");
        s.setBook_num(1);

        s.setBook(b);
        s.setCustom(c);

        iProductListService.insertShop(s);
    }
    @Test//测试根据id查book
    public void test4(){
        Map map=new HashMap();
        map.put("id",20);
        System.out.println(iProductListService.selectById(20));
    }
    @Test//测试根据name查Custom
    public void test5(){
        System.out.println(iProductListService.selectByName("张三"));
    }
/*****************************************************************************************************************/
    @Test
    public void test6(){
        Custom c=new Custom();
        c.setId(1);
        System.out.println(ljOrderListService.selectByCustom(c));
    }
    @Test
    public void test7(){
        Custom c=new Custom();
        c.setId(1);
        Address a=new Address();
        a.setCustom(c);
        a.setAddress("框框的家");
        a.setUname("框框");
        a.setPhone("110");
        System.out.println(ljOrderListService.insertAddress(a));
    }
    @Test
    public void test8(){
        System.out.println(ljOrderListService.delAddress(4));
    }
    @Test
    public void test9(){
        Address a=new Address();
        a.setId(6);
        a.setAddress("小明的家");
        a.setPhone("120");
        System.out.println(ljOrderListService.updateAddress(a));
    }
    @Test
    public void test10(){
        System.out.println(ljOrderListService.selectBy("张三").getId());
    }
    @Test//测试根据大类型id查小类型id
    public void test11(){
        System.out.println(iProductListService.selectByBtypeId(1));
    }
    @Test//数组id遍历查看
    public void test12(){
        String shuzu[]={"1","5","12"};
        System.out.println(iProductListService.selectByStype(1,3,shuzu));
    }
    @Test//查看所有
    public  void test13(){
        System.out.println(iProductListService.selectBook(1,4));
    }















    public void setiProductListService(IProductListService iProductListService) {
        this.iProductListService = iProductListService;
    }

    public IProductListService getiProductListService() {
        return iProductListService;
    }

    public LJOrderListService getLjOrderListService() {
        return ljOrderListService;
    }

    public void setLjOrderListService(LJOrderListService ljOrderListService) {
        this.ljOrderListService = ljOrderListService;
    }
}
